package com.bdqn.jiang.Service.impl;

import com.bdqn.jiang.Service.BaseService;
import com.bdqn.jiang.entity.User;
import com.bdqn.jiang.utils.ServiceFactory;

import java.util.*;

public class LoginServiceIml implements BaseService  {
    Scanner sc=new Scanner(System.in);
    User user=new User();



    @Override
    public void execute(List<User> list) {
        for (;;){
            System.out.println("请输入登录名");
            String name=sc.next();
            System.out.println("请输入密码");
            String pwd1=sc.next();

//            user.setUsername(name);
//
//            user.setUserpwd(pwd1);

            //User user1=login(list);

            for (int i = 0; i < list.size(); i++) {
                if(name.equals(list.get(i).getUsername()) && pwd1.equals(list.get(i).getUserpwd())){
                    System.out.println("登录成功！");
                    System.out.println("----------------------------");
                    BaseService baseService = ServiceFactory.getService("leix");
                    baseService.execute(list);
                    break;
                }else {
                    System.out.println("不存在该用户！S");
                    break;
                }
            }


        }
    }



}
